package com.zhuzl.stockservice.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuzl.stockservice.mapper.StockInfoMapper;
import com.zhuzl.stockservice.model.StockInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author JZY001
 */
@Service
public class StockInfoService extends ServiceImpl<StockInfoMapper, StockInfo> {

    @Transactional(rollbackFor = Exception.class)
    public void decrease(Integer id, Integer count) {
        int decrease = baseMapper.decrease(id, count);
        if (decrease < 1) {
            throw new RuntimeException("系统异常，扣减库存失败");
        }
    }
}
